package com.gmlive.common.gmshare.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.FragmentActivity
import com.gmlive.common.gmshare.share.QQShare
import com.tencent.connect.common.Constants
import com.tencent.tauth.Tencent

/**
 * Author: xs
 * Create on: 2020/06/18
 * Description: _QQ分享中转页面，用于接收QQ分享回调
 */
class QQShareHandlerActivity : FragmentActivity() {

    companion object {
        fun start(activity: Activity) {
            val intent = Intent(activity, QQShareHandlerActivity::class.java)
            activity.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        QQShare.shareWithQQOnActivity(this)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == Constants.REQUEST_QQ_SHARE || requestCode == Constants.REQUEST_QZONE_SHARE) {
            Tencent.onActivityResultData(requestCode, resultCode, data, null)
            finish()
        }
    }
}